package com.heima.apis.task;

import com.heima.apis.task.fallback.ITaskClientFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.schedule.dtos.Task;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 定时任务远程接口
 *
 * @author ybw
 * @version 1.0
 * @date 2021/12/17 18:03
 */
@FeignClient(value = "leadnews-schedule",fallback = ITaskClientFallback.class)
public interface ITaskClient {

  /**
   * 添加定时发布任务
   *
   * @param task
   * @return
   */
  @PostMapping("/api/v1/task/add")
  ResponseResult addTask(@RequestBody Task task);

  /**
   * 消费定时任务
   *
   * @param type
   * @param priority
   * @return
   */
  @GetMapping("/api/v1/task/poll/{type}/{priority}")
  ResponseResult pollTask(
      @PathVariable("type") Integer type, @PathVariable("priority") Integer priority);
}
